package com.frikinet.tools.gui;

import java.awt.Component;

import javax.swing.DefaultListCellRenderer;
import javax.swing.JLabel;
import javax.swing.JList;

public abstract class FListCellRenderer<T> extends DefaultListCellRenderer
{
	private static final long serialVersionUID = 1L;
	
	public abstract String formatValue(T value);

	@SuppressWarnings("unchecked")
	@Override
	public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus)
	{
		JLabel label = (JLabel)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
		label.setText(formatValue((T)value));
		return label;
	}
}
